import { request } from "../../utils/request";
import config from "../../utils/config";
Page({
    data: {
        picUrl: config.picUrl,
        custom: wx.getMenuButtonBoundingClientRect(),
        user:wx.getStorageSync('userInfo'),
        page:1,
        last_page:1,
        endHide:true,
        list:[]
    },
    onLoad(options) {
        
    },
    onShow(){
        this.getMessageList()
    },
    onReachBottom() {
        if(this.data.page >= this.data.last_page){
            this.setData({endHide:false})
            return false
        }
        this.setData({page:this.data.page+1})
        this.getMessageList()
    },
    getMessageList(){
        var user = wx.getStorageSync('userInfo')
        request({url:'/miniprogram/user/getMessageList',data:{page:this.data.page,user_id:user.id}}).then(res=>{
            if(this.data.page == 1){
                this.setData({list:[]})
            }
            this.setData({
                list:this.data.list.concat(res.data),
                last_page:res.last_page
            })
            if(this.data.page == res.last_page){
                this.setData({endHide:false})
            }
        })
    }

})